******************************************************************************************************************************
** PAPER: Revealing the Zone Of Possible Agreement between parties in conflict: an application to Israeli-Palestinian peace agreements, by Elisa Cavatorta, Benjamin Groom and Gilead Sher
******************************************************************************************************************************
************************************************  ISRAELIS DATA   ************************************************************
******************************************************************************************************************************
frame create rankingdataISR
frame change rankingdataISR


global rootfolder "...\Replication"

* Load the data
use "$rootfolder\Data\Israelis_ranking_data.dta"


* Rank- Ordered Logit estimation
* Sample: Representative sample (Jews: rep-sample==1, + Arab Israelis: consent_ipanel_project==1) with a minimum task's completion time of 240 seconds
    *Options: reverse --> specifies that in the preference order, a higher number means a less attractive alternative.  The default is that higher values indicate more attractive alternatives.  
	* Notes on if qualifier: if card_ranking_today_cardgam > 240 & repsample==1 | card_ranking_today_cardgam > 240 & consent_ipanel_project==1: this is not strictly necessary but we kept it as a reminder that the data is a representative sample and include observations from respondents who satisfy the quality control conditions.

rologit rank a-h if card_ranking_today_cardgam > 240 & repsample==1 | card_ranking_today_cardgam > 240 & consent_ipanel_project==1, group(player_id) reverse vce(cluster player_id)
estimates store Israel
predict I_stdp  if e(sample), stdp
matrix I_V = e(V)



* Recover coefficients as scalar
foreach v of varlist a b c d e f g h {
	gen _bHE`v' = _b[`v']
	if abs(_b[`v']) > 1.96*(_se[`v']) {
		scalar _bHE`v' = _b[`v']
	}
	else {
		scalar _bHE`v' = 0
	}
}

	
*********************************************************************************
***************************** HETEROGENEITY *************************************
*********************************************************************************
* BY GENDER (estimates for Figure SI.7 (a))

rologit rank a-h if card_ranking_today_cardgam > 240 & repsample==1 & consent_gender==0 | card_ranking_today_cardgam > 240 & consent_ipanel_project==1 & consent_gender==0 , group(player_id) reverse vce(cluster player_id)
est store Israel_women
* Recover coefficients as scalar
foreach v of varlist a b c d e f g h {
	gen _bHE_fem_`v' = _b[`v']
	if abs(_b[`v']) > 1.645*(_se[`v']) {
		scalar _bHE_fem_`v' = _b[`v']
	}
	else {
		scalar _bHE_fem_`v' = 0
	}
}

rologit rank a-h if card_ranking_today_cardgam > 240 & repsample==1 & consent_gender==1  | card_ranking_today_cardgam > 240 & consent_ipanel_project==1 & consent_gender==1, group(player_id) reverse vce(cluster player_id)
est store Israel_men
* Recover coefficients as scalar
foreach v of varlist a b c d e f g h {
	 gen _bHE_men_`v' = _b[`v']
	if abs(_b[`v']) > 1.645*(_se[`v']) {
		scalar _bHE_men_`v' = _b[`v']
	}
	else {
		scalar _bHE_men_`v' = 0
	}
}

* test the differences in valuations of components by men vs women
rologit rank a-h i.consent_gender#(a-h) if card_ranking_today_cardgam > 240 & repsample==1   | card_ranking_today_cardgam > 240 & consent_ipanel_project==1, group(player_id) reverse vce(cluster player_id)


* BY AGE (estimates for Figure SI.8)
sum consent_age, det


rologit rank a-h if card_ranking_today_cardgam > 240 & repsample==1 & consent_age >=18 & consent_age<=29 | card_ranking_today_cardgam > 240 & consent_ipanel_project==1 & consent_age >=18 & consent_age<=29, group(player_id) reverse vce(cluster player_id)  /*18-29*/
est store Israel_18_29
foreach v of varlist a b c d e f g h {
	 gen _bHE_29_`v' = _b[`v']
	if abs(_b[`v']) > 1.645*(_se[`v']) {
		scalar _bHE_29_`v' = _b[`v']
	}
	else {
		scalar _bHE_29_`v' = 0
	}
}


rologit rank a-h if card_ranking_today_cardgam > 240 & repsample==1 & consent_age >=30 & consent_age<=49 | card_ranking_today_cardgam > 240 & consent_ipanel_project==1 & consent_age >=30 & consent_age<=49, group(player_id) reverse vce(cluster player_id)  /*30-49*/
est store Israel_30_49

foreach v of varlist a b c d e f g h {
	 gen _bHE_49_`v' = _b[`v']
	if abs(_b[`v']) > 1.645*(_se[`v']) {
		scalar _bHE_49_`v' = _b[`v']
	}
	else {
		scalar _bHE_49_`v' = 0
	}
}


rologit rank a-h if card_ranking_today_cardgam > 240 & repsample==1 & consent_age >=50 & consent_age<=120 | card_ranking_today_cardgam > 240 & consent_ipanel_project==1 & consent_age >=50 & consent_age<=120 , group(player_id) reverse vce(cluster player_id)  /*50+*/
est store Israel_50_100
foreach v of varlist a b c d e f g h {
	 gen _bHE_50_`v' = _b[`v']
	if abs(_b[`v']) > 1.645*(_se[`v']) {
		scalar _bHE_50_`v' = _b[`v']
	}
	else {
		scalar _bHE_50_`v' = 0
	}
}

* Coefficient plot for Israelis only
coefplot (Israel_18_29, mcolor(olive_teal) ciopts(lcolor(olive_teal))) (Israel_30_49, mcolor(green) ciopts(lcolor(green))) (Israel_50_100, mcolor(dkgreen) ciopts(lcolor(dkgreen))), xline(0)  graphregion(fcolor(white)) xtick(-1(.1)1) coeflabels(a ="Freezing of all settlements" b="Recognition of Israel as nation-state of Jews" c = "Indepenent Palestinian State with equitable land swaps" d="Freedom of movement for all" e= "Unrestricted rights to access holy sites for all" f="Arab + Jewish-Jerusalem capital, Old City undivided" g= "Mutual amnesty for prisoners" h="Re-allocation of water rights", wrap(20)  labsize(vsmall)) legend(label(2 "18-29 years old")  label(4 "30-49 years old") label(6 "50+ years old")) title("Relative strength of preference for resolutions, Israeli citizens" "(By age)", size(medium)) subtitle("Arabs sample n=129, Israeli Jews rep n=550", size(small))


* BY EXPOSURE TO VIOLENCE (estimates for Figure 4(a) )

browse participantcode count_* 

* Knows someone (a relative, friend or acquaintance) victim of an incident of violence related to the  conflict
rologit rank a-h if card_ranking_today_cardgam > 240 & repsample==1 & count_people_know>0 | card_ranking_today_cardgam > 240 & consent_ipanel_project==1 & count_people_know>0, group(player_id) reverse vce(cluster player_id)  /*knows someone*/
est store Israel_knows_someone
foreach v of varlist a b c d e f g h {
	gen _bHE_knows_`v' = _b[`v']
	if abs(_b[`v']) > 1.645*(_se[`v']) {
		scalar _bHE_knows_`v' = _b[`v']
	}
	else {
		scalar _bHE_knows_`v' = 0
	}
}

* does not know anyone - noone 
rologit rank a-h if card_ranking_today_cardgam > 240 & repsample==1 & count_people_know==0 | card_ranking_today_cardgam > 240 & consent_ipanel_project==1 & count_people_know==0, group(player_id) reverse vce(cluster player_id)  /*no-one*/
est store Israel_noone
foreach v of varlist a b c d e f g h {
	gen _bHE_noone_`v' = _b[`v']
	if abs(_b[`v']) > 1.645*(_se[`v']) {
		scalar _bHE_noone_`v' = _b[`v']
	}
	else {
		scalar _bHE_noone_`v' = 0
	}
}


* Knows someone who died
rologit rank a-h if card_ranking_today_cardgam > 240 & repsample==1 & count_people_know>0 & count_died>0 | card_ranking_today_cardgam > 240 & consent_ipanel_project==1 &  count_people_know>0 & count_died>0, group(player_id) reverse vce(cluster player_id)  /*no-one, n=166, much more opposed to freedom of movemenet and independent Palestinian state*/
est store Israel_died
foreach v of varlist a b c d e f g h {
	 gen _bHE_died_`v' = _b[`v']
	if abs(_b[`v']) > 1.645*(_se[`v']) {
		scalar _bHE_died_`v' = _b[`v']
	}
	else {
		scalar _bHE_died_`v' = 0
	}
}



